#!/usr/bin/env python
import os,sys


def show_dir(dir):
    list = []
    list = os.listdir(dir)
    info = {}
    i = 0
    for item in list:
        if item.find("NODE_V") != -1:
            array = item.strip().split('_')
            info[i] = array
            i+=1
    return info

def select(info):
    list = sorted(info.iteritems() , key=lambda d:d[1][3])
    return list[0][1]

def put(info , url):
    print url
    ip = info[2][1:]
    ip = "192.168.2."+ip
    name = url.strip().split("/")[1]
    cmd = ""
    cmd = "wput " + url + " ftp://haha:haha818@192.168.9.74/chenkangrui/"+name
    os.system(cmd)
    
if __name__ == '__main__':
    dic_info = {}
    dic_info = show_dir(os.getcwd())
    #sel_info = select(dic_info)
    put(sel_info , sys.argv[1])
